using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameLib.GameItem
{
    class LevelButton : GameButton
    {
        Color textColor = Color.White;
        SpriteFont textFont;
        String buttonText;
        Vector2 textPos;
        
        Texture2D arTexture;
        Vector2 arPos;

        public LevelButton(Texture2D texture, Texture2D aTexture, Vector2 pos, String text, SpriteFont font, Color color, ItemManager man)
            : base(texture, pos, text, font, man)
        {
            arTexture = aTexture;
            arPos.X = Position.X + 10;
            arPos.Y = Position.Y + 62;

            if (font != null)
            {
                buttonText = text;
                textFont = font;
                textColor = color;
                Vector2 textSize = textFont.MeasureString(text);
                textPos.X = Position.X + (Texture.Width - textSize.X) / 2;
                textPos.Y = Position.Y - 12 + (Texture.Height - textSize.Y) / 2;
            }
        }

        public override void Draw(SpriteBatch sp)
        {
            sp.Draw(Texture, Position, Color.White);

            if (arTexture != null)
            {
                sp.Draw(arTexture, arPos, Color.White);
            }

            if (textFont != null)
            {
                if (Trans != Transition.None)
                {
                    if (Enable)
                    {
                        sp.DrawString(textFont, buttonText, textPos, textColor * Alpha);
                    }
                    else
                    {
                        if (Alpha > 0.5f)
                        {
                            sp.DrawString(textFont, buttonText, textPos, textColor * 0.5f);
                        }
                        else
                        {
                            sp.DrawString(textFont, buttonText, textPos, textColor * Alpha);
                        }
                    }
                }
                else
                {
                    if (Enable)
                    {
                        sp.DrawString(textFont, buttonText, textPos, textColor);
                    }
                    else
                    {
                        sp.DrawString(textFont, buttonText, textPos, textColor * 0.5f);
                    }
                }
            }
        }
    }
}
